//package com.diligent.cloud.sfc.config;
//
//import com.alibaba.fastjson.JSONObject;
//import com.canny.commons.model.ObjectResult;
//import com.canny.commons.model.Result;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.google.gson.JsonObject;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.core.MethodParameter;
//import org.springframework.http.MediaType;
//import org.springframework.http.server.ServerHttpRequest;
//import org.springframework.http.server.ServerHttpResponse;
//import org.springframework.web.bind.annotation.ControllerAdvice;
//import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
//
//import java.util.List;
//
///**
// * RespondeBodyConfig class
// *
// * @author xf107278
// * @date 3/30/2020
// */
//@ControllerAdvice
//@Slf4j
//public class RespondeBodyConfig implements ResponseBodyAdvice {
//    @Override
//    public boolean supports(MethodParameter returnType, Class converterType) {
//        return true;
//    }
//
//    @Override
//    public Object beforeBodyWrite(Object resBody, MethodParameter returnType, MediaType selectedContentType,
//                                  Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//        List<String> flag = request.getHeaders().get("flag");
//        if(flag != null && flag.size() > 0 && flag.get(0).equals("feign")){
//            return resBody;
//        }
//        String string = JSONObject.toJSONString(resBody);
//        ObjectResult result = JSONObject.parseObject(string, ObjectResult.class);
//        return result;
//    }
//}
